home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Merciful 2
/
Merciful - Disc 2.iso
/
software
/
i
/
ian'simagineutilsv1.3.lha
/
IIUtilities
/
StageShift
< prev
next >
Wrap
Text File
|
1995-01-14
|
3KB
|
92 lines
/*\
* This script will add a specified number of empty frames to the
* beginning of an Imagine staging file. Should work with v3.1+
*
* Usage: StageShift <stageFileName> <frames>
*
* Notes:
* Each object is given a line of its own in the output. A "." is
* displayed for each timeline bar that is modified.
* This is not very usefull unless you have the ISL language by
* John Grieggs to join multiple projects together. I am not
* sure if it works since I don't have a copy. Beware of changing
* camera sizes and such in one project, and using the defaults in
* another. If you join them together, any project with defaults
* will inherit the valuse of the previous project. So watch out.
* The former stage file will be renamed to <filename>.old and saved.
*
* V1.0 Jan-14-94
* IanSmith@moose.erie.net
*
\*/
Numeric Digits 14 /* Need at least 12 to handle 32 bits */
Parse Arg FileName Change .
If Change="" Then Do
Say "Usage: StageShift <stageFileName> <frames>"
Say " More help can be found in the header of this file."
Exit
End
MaxFrames=0
Temp="Temp$Stage."||Date(D)||Time(S) /* Create temp filename */
Address Command 'Delete >NIL:' FileName||".Old" /* Erase backup file */
If Open(Out,Temp,"W")=0 Then Do
Say "Can't open temp staging file!"
Exit
End
If Open(In,FileName,"R")=0 Then Do
Say "Can't find '"FileName"' to open!"
Exit
End
Call Open(Text,"*","W")
Call WriteCH(Text,"Shifting '"||FileName||"' forward "||Change||" frames.")
Call ParseStaging(C2D(SubStr(ReadWrite(In,12),5,4)))
Call WriteLN(Text,"") Close(In) Close(Out) Close(Text)
Address Command 'Rename' FileName 'To' FileName||".Old"
Address Command 'Rename' Temp 'To' FileName
Exit
ParseStaging: PROCEDURE EXPOSE Change MaxFrames
Parse Arg MaxSize /* Recursive Function */
TotalSize=4; New=0
Do Until TotalSize>=MaxSize /* Read MaxSize Bytes */
LastName=Name
Name=ReadWrite(In,4)
If Name~=LastName Then New=0
Size=C2D(ReadWrite(In,4))
If Size//2=1 Then Size=Size+1 /* Add pad byte if needed */
If Name="ISTG" | Name="SOBJ" Then Do
TotalSize=TotalSize+ParseStaging(Size)+8 /* Parse into these hunks */
Iterate
End
TotalSize=TotalSize+Size+8 /* Add SIZE and NAME length */
If Name="NAME" Then
Call WriteCH(Text,'0A'x||" "||ReadWrite(In,Size))
Else If Name="MAXF" Then Do
MaxFrames=C2D(ReadCH(In,Size))
Call WriteCH(Out,Right(D2C(MaxFrames+Change),2,'00'x))
End; Else If Index("LOOP-NAME-STGF-LYR0", Name)=0 Then Do
Call WriteCH(Text,".")
Buffer=ReadCH(In,Size)
StartF=C2D(SubStr(Buffer,3,2))
EndF=C2D(SubStr(Buffer,5,2))
If (StartF>0 & StartF<=MaxFrames & EndF>0 & EndF<=MaxFrames & StartF<=EndF) Then Do
Buffer=Overlay(Right(D2C(StartF+Change),2,'00'x),Buffer,3)
Buffer=Overlay(Right(D2C(EndF+Change),2,'00'x),Buffer,5)
End; Else Do
Say "Hunk" Name "is not a valid timeline!"
End
Call WriteCH(Out,Buffer)
End; Else
Call ReadWrite(In,Size)
End
Return TotalSize
ReadWrite:
Parse Arg FileHandle , Bytes .
RWBuffer=ReadCH(FileHandle, Bytes)
Call WriteCH(Out,RWBuffer)
Return RWBuffer